<?php



function callService_authenticate($pdio, $input) {
    $err = '';
    
	try {
		list($storedHpwd, $salt) = AuthDao::getHPwd($pdio, $input['uname']);
		$hpwd =  hash('whirlpool',$salt.$input['pwd']);
		if ($storedHpwd == $hpwd) {
		    $logOk = 1;
		} else {
		    $logOk = 0;
		    $err = 'Wrong password';
		}
	} catch (WrongLoginException $wle) {
	    $err = 'User not found';
	    $logOk = 1;
	}
	
	return array( 'esito' => $logOk, 'msg' => $err);
}

function callService_register($pdio, $input) {

    $mDao = new ModulesDao($pdio);
    return $mDao->retrieveList();
}